package pl.edu.mimuw.irs.core.model.design.atomic;

import pl.edu.mimuw.irs.core.global.IDManager;
import pl.edu.mimuw.irs.core.model.petrinet.Place;
import pl.edu.mimuw.irs.core.model.petrinet.Transition;

public class DefaultNodeFactory implements INodeFactory {

	// *** Attributes
	
	private IDManager idManager;
	public IDManager getIdManager() {
		return idManager;
	}
	public void setIdManager(IDManager idManager) {
		this.idManager =idManager;
	}
	
	// *** Constructors
	
	public DefaultNodeFactory(IDManager idManager) {
		setIdManager(idManager);
	}
	
	// *** Methods
	
	@Override
	public Place copyPlace(Place place) {
		return new Place(getIdManager(),
				getIdManager().getPrefixedNewId(place.getName()), 
				place.getPosition(), place.getTokens());
	}
	
	@Override
	public Transition copyTransition(Transition transition) {
		return new Transition(getIdManager(),
				getIdManager().getPrefixedNewId(transition.getName()), 
				transition.getPosition());
	}
	
}
